#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 4) {
        cout << "Usage: " << argv[0] << " lex_file word1 word2" << endl;
        return 0;
    }

    vector<char *> lex;
    vector<char *> word_list;
    char word1[255];
    char word2[255];
    char lex_file[255];

    strcpy(lex_file, argv[1]);
    strcpy(word1, argv[2]);
    strcpy(word2, argv[3]);

    bool ret;
    ret = createLex(lex_file, lex);
    if (!ret) {
        cout << "Create lexicon error!" << endl;
        return 0;
    }

    ret = transformWordBreadthFirstSearch(word1, word2, lex, word_list);
    if (ret == false) {
        cout << "Input words cannot be transformed from one to the other!" << endl;
    }
    else {
        cout << "Word list is:" << endl;
        vector<char *>::reverse_iterator rit;
        for (rit = word_list.rbegin(); rit != word_list.rend(); rit++) {
            cout << *rit << "\t";
        }
        cout << endl;
    }
    
    return 0;
}

